$(function(){
    if(localStorage.userName=="null" || localStorage.userName==undefined ||  localStorage.userName==""){
    alert("请先登录");
    window.location.href="login.html";
    }else{
        if(localStorage.idNum=="null" || localStorage.idNum==undefined ||  localStorage.idNum==""){
            alert("请先完善个人信息");
            window.location.href="personinfo.html";
        }
    }
    $('.wrapper').navbarscroll();
    getall();
    $(".scroller").css("width","100%");
    $(".scroller ul li").css("width","50%");
    $(".cxzt").click(function(){
        if($(this).attr("zt")==0){
        $.ajax({
            url:requestUrl+"/app/queryApplySchedule.do",
            type:"GET",
            data:{
                "token":window.sessionStorage.getItem("token"),
                "userId":localStorage.getItem("userId")
            },
            dataType:"JSON",
            success:function(json){
                if (json.code==0){
                $(".jdqk").children().remove();
                    $(json.data).each(function (i,o) {
                        var div = $(" <div class='jdcard'><div class='dqjd'><span>当前进度：</span><span class='dqjdzt'>"+o.scheduleName+"</span></div><div class='ywh'>业务号:<span class='ywhm'>"+o.bussinessNo+"</span></div><div class='ywh'><span class=''>"+o.date+""+o.bussinessName+"</span></div></div>").appendTo(".jdqk");
                    })
                }else{
                    alert(json.message)
                }
            }
        })
        }else if ($(this).attr("zt")==2) {
        $.ajax({
            url:requestUrl+"/app/queryApplySchedule.do",
            type:"GET",
            data:{
                "token":window.sessionStorage.getItem("token"),
                "userId":localStorage.getItem("userId")
            },
            dataType:"JSON",
            success:function(json){
                if (json.code==0){
                $(".jdqk").children().remove();
                    $(json.data).each(function (i,o) {
                        if (o.scheduleName=="已申请") {
                            var div = $(" <div class='jdcard'><div class='dqjd'><span>当前进度：</span><span class='dqjdzt'>"+o.scheduleName+"</span></div><div class='ywh'>业务号:<span class='ywhm'>"+o.bussinessNo+"</span></div><div class='ywh'><span class=''>"+o.date+""+o.bussinessName+"</span></div></div>").appendTo(".jdqk");
                        }
                    })
                }else{
                    alert(json.message)
                }
            }
        })
        }else if ($(this).attr("zt")==3) {
        $.ajax({
            url:requestUrl+"/app/queryApplySchedule.do",
            type:"GET",
            data:{
                "token":window.sessionStorage.getItem("token"),
                "userId":localStorage.getItem("userId")
            },
            dataType:"JSON",
            success:function(json){
                if (json.code==0){
                $(".jdqk").children().remove();
                    $(json.data).each(function (i,o) {
                        if (o.scheduleName=="已领取") {
                            var div = $(" <div class='jdcard'><div class='dqjd'><span>当前进度：</span><span class='dqjdzt'>"+o.scheduleName+"</span></div><div class='ywh'>业务号:<span class='ywhm'>"+o.bussinessNo+"</span></div><div class='ywh'><span class=''>"+o.date+""+o.bussinessName+"</span></div></div>").appendTo(".jdqk");
                        }
                    })
                }else{
                    alert(json.message)
                }
            }
        })
        }
    })
});

function getall() {
    $.ajax({
        url:requestUrl+"/app/queryApplySchedule.do",
        type:"GET",
        data:{token:window.sessionStorage.getItem("token"),userId:localStorage.userId},
        dataType:"JSON",
        success:function(json){
            if (json.code==0){
                $(".jdqk").children().remove();
                $(json.data).each(function (i,o) {
                    if (o.scheduleName=="已申请") {
                        var div = $(" <div class='jdcard'><div class='dqjd'><span>当前进度：</span><span class='dqjdzt'>" + o.scheduleName + "</span></div><div class='ywh'>业务号:" + o.bussinessNo + "</div><div class='ywh'><span class=''>" + o.date + "" + o.bussinessName + "</span></div></div>").appendTo(".jdqk");
                    }
                })
            }else{
                // if(json.message=="用户尚未登陆"){
                //     window.location.href="login.html";
                // }else{
                //     alert(json.message);
                // }
            }
        }
    })
}